#include <iostream>
#include <pthread.h>
#include <unistd.h>
using namespace std;
int n=5;
void *thread1(void *p)
{
    while (--n>0)
    {
        printf("I am thread$:%s\n", (const char *)p);
        sleep(1);
    }
    cout<<pthread_self()<<endl;
    return nullptr;
}
int main()
{
    pthread_t tid;
    pthread_create(&tid, nullptr, thread1, (void *)"hello thread");
    while (--n>0)
    {
        printf("I am main\n");
        sleep(1);
    }
    cout<<tid<<endl;
    void* ret;
    pthread_join(tid,&ret);
    cout<<ret<<endl;
    return 0;
}